package org.example.zrccddllljh.Service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.codec.binary.Base16OutputStream;
import org.example.zrccddllljh.Mapper.DockerListMapper;
import org.example.zrccddllljh.Pojo.Doctor;
import org.example.zrccddllljh.Service.DockerlListServie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DockerlListServieImpl  implements DockerlListServie {
    @Autowired
    private DockerListMapper dockerListMapper;
    @Override
    public List<Doctor> list() {
        return   dockerListMapper.list();
    }

    @Override
    public void upadte(Doctor doctor) {
        doctor.setUpdateTime(LocalDateTime.now());
        dockerListMapper.uptate(doctor);
    }

    @Override
    public void add( Doctor doctor) {
doctor.setUpdateTime(LocalDateTime.now());
doctor.setCreateTime(LocalDateTime.now());
       dockerListMapper.add(doctor);

    }

    @Override
    public void deleteById(Integer id) {
        dockerListMapper.deleteById(id);
    }



    @Override
    public List<Doctor> list(Integer pageNow, Integer pageSize) {


        PageHelper.startPage(pageNow,pageSize);
        List<Doctor> orderInfoList = dockerListMapper.getOrderInfoList();
        PageInfo<Doctor> docker = new PageInfo<>(orderInfoList);
        return docker.getList();

    }

    @Override
    public List<Doctor> list(Integer pageNow, Integer pageSize, String department, String state) {
        PageHelper.startPage(pageNow,pageSize);
        List<Doctor> orderInfoList = dockerListMapper.getOrderInfoLists(department, state);
        PageInfo<Doctor> docker = new PageInfo<>(orderInfoList);
        return docker.getList();
    }
}
